module.exports = function ($scope, getDate, toaster, travel, $resource, $modalInstance) {

	//日历要显示的数据
	$scope.data = [];

	$scope.dateArray = {};

	//日历显示信息的顺序和样式
	$scope.showattrarr = [
		{
			key: 'guide_name',
			position: 'left',
			before: '<font color=red >导游: </font>'
		},
		{
			key: 'price',
			position: 'left',
			before: '<font color=red >价格: ¥</font>'
		}
	];


	//查询数据
	$scope.findinfoList = function () {
		var para = {
			'group_code': travel.group_code
		}
		$resource('/api/as/goc/outboundtravel/getOutboundSaleList', {}, {}).save(para, function (res) {
			if (res.errcode === 0) {
				for (var index = 0; index < res.data.length; index++) {
					var temp = res.data[index];
					$scope.dateArray[temp.travel_time] = temp.id;
					var element = {
						'd': temp.travel_time,
						'price': '<font color=red >' + temp.price/100 + '</font>',
						'guide_name': '<font color=red >' + temp.guide_name + '</font>',
						'price_a': temp.price,
						'sale_code': temp.sale_code,
						'address': temp.address,
						'guide_name_a': temp.guide_name,
						'guide_mobile': temp.guide_mobile,


					};
					$scope.data[index] = element;
				}
				$scope.loadupdate();
			} else {
				toaster.error({ title: '', body: '查询失败'});
			}
		});
	}
	$scope.findinfoList();

    $scope.options = {
		btn_flag: false,//是否显示按钮
		leftClick: function () {//左按钮函数
		},
		rightClick: function(){//右按钮函数
		},
		click: function (item) {//每天的点击事件
			if(item.d == '0' || item.d == 0){
				toaster.info({ title: '', body: '请选择当月日期' });
				return false;
			}
			var today = getDate(new Date());
			if (item.d < today) {
				toaster.warning({ title: item.d, body: '出游日期不能小于当天日期' });
				return false;
			}
			if (item.labelarr.length < 1) {
				toaster.warning({ title: item.d, body: '未设置价格日期无法选择' });
				return false;
			}
			item.data.date = item.data.d;
			$modalInstance.close(item.data);

		},
		state: 'state',
		checkbox: false
	}
}